package com.example.projectmanagement.service.study;

import com.example.projectmanagement.model.study.Video;
import com.example.projectmanagement.repository.study.VideoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoService {
    
    @Autowired
    private VideoRepository videoRepository;
    
    public Video save(Video video) {
        return videoRepository.save(video);
    }
    
    public Iterable<Video> findAll() {
        return videoRepository.findAll();
    }
    
    public Video findById(Long id) {
        return videoRepository.findById(id).orElse(null);
    }
    
    public void deleteById(Long id) {
        videoRepository.deleteById(id);
    }
    
    public List<Video> findByCourseIdAndStatus(Long courseId, String status) {
        return videoRepository.findByCourseIdAndStatus(courseId, status);
    }
    
    public List<Video> findByStatus(String status) {
        return videoRepository.findByStatus(status);
    }
    
    public List<Video> findAllByUserId(Long userId) {
        return videoRepository.findAllByUserId(userId);
    }
}